<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>一朵 -- 提交订单</title>
    <!-- swiper-2.7css -->
    <link rel="stylesheet" href="__STATIC__/index/js/swiper/idangerous.swiper.css">
    <!-- swiper-2.7js -->
    <script src="__STATIC__/index/js/swiper/idangerous.swiper.min.js"></script>
    <!-- jquery-3.2.1引用 -->
    <script src="__STATIC__/index/js/global/jquery-3.2.1.min.js"></script>
    <!-- 阿里巴巴矢量图库 -->
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_561814_zzcoprfrpkj.css">
    <!-- 公共头部 脚部 -->
    <link rel="stylesheet" href="__STATIC__/index/css/global/global.css">
    <!-- 超过1200屏幕 -->
    <link rel="stylesheet" media="screen and (min-width: 1200px)" href="__STATIC__/index/css/order/order1200.css" />
    <!-- 1080-1200 -->
    <link rel="stylesheet" media="screen  and (min-width: 1080px) and (max-width: 1199px) " href="__STATIC__/index/css/order/order1080.css"
    />
    <!-- 960-1080 -->
    <link rel="stylesheet" media="screen  and (min-width: 960px) and (max-width: 1079px) " href="__STATIC__/index/css/order/order960.css"
    />
    <!-- 768-959 -->
    <link rel="stylesheet" media="screen  and (min-width: 768px) and (max-width: 959px) " href="__STATIC__/index/css/order/order768.css"
    />
    <!-- 568-767 -->
    <link rel="stylesheet" media="screen  and (min-width: 568px) and (max-width: 767px) " href="__STATIC__/index/css/order/order568.css"
    />
    <!-- 375-567 -->
    <link rel="stylesheet" media="screen  and (min-width: 375px) and (max-width: 567px) " href="__STATIC__/index/css/order/order375.css"
    />
    <!--引入layer-->
    <script src="__STATIC__/layer/layer.js"></script>
    <!-- 小于375-->
    <link rel="stylesheet" media="screen  and (max-width: 374px) " href="__STATIC__/index/css/order/order320.css" />
</head>
<body>
    <form id="order_form" action="{:url('GoodsList/pre_pay_order')}" method="post">
        <div class="M">
            <div class="m-header">
                <div>
                    <span>
                        <span class="iconfont icon-xiangzuo" onclick="go_back();"></span>
                        返回
                    </span>
                    <span>提交订单</span>
                    <span>
                        <a href="{:url('User/index')}" class="my" {if condition="empty($realname)" }style="display: none" {/if}>
                            {$realname}
                        </a>
                                                                                                                           {if condition="empty($realname)"}
                        <a href="{:url('Login/loginin')}">登录</a>
                        <a href="{:url('Login/register')}">注册</a>
                        {/if}
                        <a href="{:url('MyCart/my_cart')}" class="car">
                            <span class="iconfont icon-gouwuche"></span>
                            <span>{$cart_num}</span>
                        </a>
                    </span>
                </div>
            </div>
            <!-- 地址选择 -->
            <div class="m-addressZong">
                    <div class="m-xuan">
                        <div class="m-xuanze m-xuanze-zhong" data-id="0">收货地址</div>
                        <div class="m-xuanze " data-id="1">自取地址</div>
                    </div>
                    <div class="m-xuan-content m-address">
                        <div>
                            {if condition="!empty($address)"}
                            <p class="m-default-address">{$default_address.address}</p>
                            <p>
                                <span class="m-default-consignee">
                                    {$default_address.consignee}
                                </span>
                                <span>{$default_address.mobile}</span>
                            </p>
                            {/if} {if condition="empty($default_address)"}
                            <p class="m-qing">请选择地址</p>
                            {/if}
                            <i class="iconfont icon-xiangyoujiantou"></i>
                        </div>
                    </div>
                <!-- <div class="m-xuan-content m-address">
                    <div>
                        <p>
                            <span>
                            </span>
                            <span></span>
                        </p>
                        <i class="iconfont icon-xiangyoujiantou"></i>
                    </div>
                </div> -->
                    <div class="m-xuan-content m-address1">
                        <div>
                            <p>
                                <i class="iconfont icon-dizhi"></i>
                                <span>自选地址</span>
                            </p>
                            <p>{$store_info.address}</p>
                            <p>
                                <span>
                                    联系方式：
                                </span>
                                <span>
                                    <a href="tel:{$store_info.mobile}">{$store_info.mobile}</a>
                                </span>
                            </p>
                        </div>
                    </div>
                </div>
            <!--
                        {if condition="!empty($address)"}
                        <div class="m-address">
                            <div>
                                <div>
                                    <i class="iconfont icon-dizhi"></i>
                                </div>
                                <div>
                                    <p class="m-default-consignee">
                                        {$default_address.consignee}
                                    </p>
                                    <p class="m-default-mobile">{$default_address.mobile}</p>
                                    <p class="m-default-address">
                                        {$default_address.address}
                                    </p>
                                </div>
                                <div>
                                    选择地址
                                </div>
                            </div>
                        </div>
                        {/if} {if condition="empty($default_address)"}
                        <div class="m-address">
                            <div>
                                <i class="iconfont icon-dizhi"></i>
                            </div>
                            <div>
                                <p>
                                    请选择您的收货地址
                                </p>
                            </div>
                            <div>
                                选择地址
                            </div>
                        </div>
                        {/if} -->
            <!-- 地址选择 -->
            <div class="m-address-popups">
                <div class="m-address-popups-content">
                    <p>选择地址
                        <i class="iconfont icon-cuowu m-address-esc"></i>
                    </p>
                    <div>
                        <!-- 移动端地址选择循环开始 -->
                        {foreach name="address" item="v"}
                        <div class="m-address-xuanze  {if condition='$v.is_default eq 1'}  m-address-zhong {/if}" data-id="{$v.id}" data-address="{$v.address}">
                            <div>
                                <span>
                                    <i class="iconfont icon-fangzi"></i>
                                </span>
                                <span>
                                    <p class="m-sh-address">{$v.address}</p>
                                    <p>
                                        <span class="m-sh-consignee">{$v.consignee}</span>
                                        <span class="m-sh-mobile">{$v.mobile}</span>
                                    </p>
                                </span>
                                <span>
                                    <img src="__STATIC__/index/img/order/m_address.png" alt="">
                                </span>
                            </div>
                        </div>
                        {/foreach}
                        <!-- 移动端地址选择循环结束 -->
                    </div>
                    <span class="m-tianjia">
                        <i class="iconfont icon-tianjia"></i>
                        <span>
                            添加收货地址
                        </span>
                    </span>
                </div>
            </div>
            <!-- 填写新的收货地址 -->
            <div class="m-address-xin">
                <div class="m-address-xin-content">
                    <p>添加新地址
                        <i class="iconfont icon-cuowu m-tianjia-esc"></i>
                    </p>
                    <!-- 名字填写 -->
                    <div class="m-address-name">
                        <div>
                            <label for="m-address-name">姓名</label>
                            <input type="text" id="m-address-name" placeholder="请填写收货人姓名" name="m_consignee">
                        </div>
                    </div>
                    <!-- 联系方式填写 -->
                    <div class="m-address-phone">
                        <div>
                            <label for="m-address-phone">手机号</label>
                            <input type="text" id="m-address-phone" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请填写手机号" name="m_mobile">
                        </div>
                    </div>
                    <!-- 城市选择 -->
                    <div class="m-address-address">
                        <div>
                            <label for="m-address-phone">地址选择</label>
                            <select name="m_city" id="m_city">
                                {foreach name="city" item="v"}
                                <option value="{$v.value}">{$v.value}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <!-- 名字填写 -->
                    <div class="m-address-detailAddress">
                        <div>
                            <label for="m-address-name">详细地址</label>
                            <input type="text" id="m-address-name" placeholder="请输入详细地址" name="m_address">
                        </div>
                    </div>
                    <div class="m-address-tacitly">
                        <div>
                            <label for="m-tacitly">
                                <span>
                                    <img id="m-tacitly-img" src="__STATIC__/index/img/order/tacitly.png" alt="">
                                </span>
                                <input type="checkbox" id="m-tacitly" name="m_default">
                                <span>设置为默认地址</span>
                            </label>
                        </div>
                    </div>
                    <a href="javascript:;" onclick="m_post_address();">
                        保存地址
                    </a>
                </div>
            </div>
            <!-- 商品循环 -->
            <div class="m-goods">
                {foreach name="goods" item="v"}
                <!-- <div>
                    <div>
                        <p>{$v.name}</p>
                        <p>{$v.spec_title}</p>
                    </div>
                    <div>
                        <p>
                            <span>{$v.goods_price}</span>
                            <span>x{$num}</span>
                        </p>
                    </div>
                    <div>
                        <img src="{$v.logo}" alt="">
                    </div>
                </div> -->
                <div>
                        <div>
                            <div>
                                <p>{$v.name}</p>
                                <p>{$v.spec_title}</p>
                            </div>
                            <div>
                                <p>
                                    <span>{$v.goods_price}</span>
                                    <span>x{$num}</span>
                                </p>
                            </div>
                            <div>
                                <img src="{$v.logo}" alt="">
                            </div>
                        </div>
                    </div>
                {/foreach}
            </div>
            <!-- 订单信息 -->
            <div class="m-time">
                <div>
                    <div>
                        <i class="iconfont icon-shijian"></i>
                    </div>
                    <div>
                        <p>
                            <span>下单时间</span>
                            <span>{$nowtime}</span>
                        </p>
                    </div>
                </div>
                <div>
                    <div>
                        <i class="iconfont icon-dingdan"></i>
                    </div>
                    <div>
                        <p>
                            <span>订单号</span>
                            <span>{$order_sn}</span>
                        </p>
                    </div>
                </div>
            </div>
            <!-- 订单金额和优惠券 -->
            <div class="m-money">
                <div>
                    <div>
                        <i class="iconfont icon-qianbao1"></i>
                    </div>
                    <div>
                        <p id="m_yunfei">
                            <span>运费</span>
                            <span class="m-yunfei">￥{$delivery_fee}</span>
                        </p>
                        <p>
                            <span>商品总额</span>
                            <span>￥{$total_amount}</span>
                        </p>
                    </div>
                </div>
                <div>
                    <div>
                        <i class="iconfont icon-wodeyouhuijuan"></i>
                    </div>
                    <div>
                        <p>
                            <span>优惠券</span>
                            {if condition="$count_coupon neq 0" }
                            <span class="m-discounts-xuan">选择优惠券></span>
                            {else /}
                            <span>暂无优惠券</span>
                            {/if}
                        </p>
                        <p>
                            <span>代金券</span>
                            {if condition="$count_cash_coupon neq 0"}
                            <span class="m-discount-xuan m-voucher-xuan">选择代金券></span>
                            {else /}
                            <span>暂无代金券</span>
                            {/if}
                        </p>
                    </div>
                </div>
            </div>
            <!-- 选择支付方式 -->
            <div class="m-pay">
                <div>
                    <div {if condition="$is_weixin eq 0" } class="weixin-icon" {/if}>
                        <i class="iconfont icon-tubiaolunkuo-"></i>
                    </div>
                    <div>
                        {if condition="$is_weixin eq 0"}
                        <p class="m_pay" onclick="m_change_pay(this)" data-type="1">
                            <span>支付宝支付</span>
                            <span>
                                <img src="__STATIC__/index/img/order/pay.png" alt="">
                            </span>
                        </p>
                        {/if}
                        <p class="m_pay" onclick="m_change_pay(this)" data-type="2">
                            <span>微信支付</span>
                            <span>
                                <img src="__STATIC__/index/img/order/pay.png" alt="">
                            </span>
                        </p>
                        <p class="m_pay" onclick="m_change_pay(this)" id="m_yu" data-type="3">
                            <span>余额支付</span>
                            <span>
                                <img src="__STATIC__/index/img/order/pay.png" alt="">
                            </span>
                        </p>
                    </div>
                </div>
            </div>
        <!-- 应付总额 -->
            <div class="m-zonge">
                <div>
                    <div>
                    </div>
                    <div>
                        <p>
                            应付总额
                        </p>
                    </div>
                    <div class="m-final-amount">
                        ￥{$final_amount}
                    </div>
                </div>
            </div>
        <!--填写备注 -->
            <div class="m-remark">
                <div>
                    <div>
                        <i class="iconfont icon-icon--"></i>
                    </div>
                    <div>
                        <input class="m_user_note" type="text" placeholder="请填写备注" name="user_note" onchange="get_user_note(this)">
                    </div>
                </div>
            </div>
        <!-- 底部浮动框 -->
            <div class="m-foot">
                <div>
                    <a href="javascript:;" onclick="quxiao_order();">取消订单</a>
                    <a href="javascript:;" onclick="check_form();">立即付款</a>
                </div>
            </div>
        <!-- 优惠券弹出框 -->
            <div class="m-discounts-popups">
                <div class="m-discounts-popups-content">
                    <p>选择优惠券
                        <i class="iconfont icon-cuowu m-discounts-esc"></i>
                    </p>
                    <!-- 移动端优惠券循环开始 -->
                    {foreach name="coupon" item="v"}
                    <div class="youhuiuan-change" data-id="{$v.id}" data-price="{$v.reduce}">
                        <div>
                            <img src="{$v.img}" alt="">
                        </div>
                        <div>
                            <div>
                                <p>
                                    <span>￥</span>
                                    <span>{$v.reduce}</span>
                                </p>
                            </div>
                            <div>
                                <p>满{$v.morethan}减{$v.reduce}</p>
                                <p>{$v.use_start_time|date="Y-m-d",###} - {$v.use_end_time|date="Y-m-d",###}</p>
                            </div>
                            <div>
                                <span>
                                    使用
                                </span>
                            </div>
                        </div>
                    </div>
                    {/foreach}
                    <!-- 移动端优惠券循环结束 -->
                </div>
            </div>
        <!-- 打折券弹出框 -->
            <div class="m-discount-popups">
                <div class="m-discount-popups-content">
                    <p>选择打折券
                        <i class="iconfont icon-cuowu m-discount-esc"></i>
                    </p>
                    <!-- 移动端打折券循环开始 -->
                    {foreach name="cash_coupon" item="v"}
                    <div class="m_daijinquan" data-id="{$v.id}" data-price="{$v.value}">
                        <div>
                            <img src="{$v.img}" alt="">
                        </div>
                        <div>
                            <div>
                                <p>立减￥{$v.value}
                                </p>
                            </div>
                            <div>
                                <p>{$v.value}</p>
                                <p>无期限</p>
                            </div>
                        </div>
                    </div>
                    {/foreach}
                    <!-- 移动端优惠券循环结束 -->
                </div>
            </div>
        </div>
        <div class="PC">
            {include file="public/p_header" /}
            <div class="pc-headline">
                <p>
                    <span>
                        <span></span> 选择商品
                    </span>
                    <span>-------------</span>
                    <span class="pc-gaoliang">
                        <span></span>确认订单</span>
                    <span>-------------</span>
                    <span>
                        <span></span>付款</span>
                    <span>-------------</span>
                    <span>
                        <span></span>交易完成</span>
                </p>
            </div>
            <div class="pc-xuan">
                    <div class="pc-xuanze pc-xuanze-zhong" data-id="0">收货地址</div>
                    <div class="pc-xuanze " data-id="1">自取地址</div>
            </div>
            <div class="pc-xuan-content pc-address">
                {foreach name="address" item="v"}
                <div class="pc-address-content {if condition='$v.is_default eq 1'} cur_address {/if}" {if condition="$v.is_default eq 1"
                     } style="border: 1px solid rgb(248, 48, 48);" {/if} data-id="{$v.id}" data-address="{$v.address}" data-consignee="{$v.consignee}"
                    data-mobile="{$v.mobile}" onclick="change_address(this);">
                    <p>{$v.consignee}
                        <i class="iconfont icon-dizhi"></i>
                    </p>
                    <p>{$v.mobile}</p>
                    <p>{$v.city}</p>
                    <p>{$v.address}</p>
                </div>
                {/foreach}
                <div class="pc-address-xin" id="p_address_list">
                    <p>+</p>
                    <p>使用新的地址</p>
                </div>
            </div>
            <div class="pc-xuan-content pc-ziqu">
                    <p>
                        <span>自取地址:</span>
                        <span>{$store_info.address}</span>
                    </p>
                    <p>
                        <span>联系电话:</span>
                        <span>{$store_info.mobile}</span>
                    </p>
            </div>
        <!-- 列表 -->
            <div class="pc-list">
                <div>
                    <div>
                        <span>商品</span>
                    </div>
                    <div>单价</div>
                    <div>数量</div>
                    <div>小计</div>
                </div>
            </div>
        <!-- 商品循环 -->
            <div class="pc-goods">
                {foreach name="goods" item="v"}
                <div>
                    <div>
                        <div>
                            <img src="{$v.logo}" alt="">
                        </div>
                        <div>
                            <p>{$v.name}</p>
                            <p>{$v.spec_title}</p>
                        </div>
                    </div>
                    <div>¥{$v.goods_price}</div>
                    <div>{$num}</div>
                    <div>¥{$total_amount}</div>
                </div>
                {/foreach}
            </div>
        <!-- 下单时间 -->
            <div class="pc-time">
                <p>
                    <span class="iconfont icon-shijian"></span>
                    <span>下单时间</span>
                    <span>{$nowtime}</span>
                    <span class="pc-youhui">
                        <span>优惠券:</span>
                        {if condition="$count_coupon neq 0" }
                        <span class="pc-discounts-xin">选择优惠券></span>
                        {else /}
                        <span>暂无优惠券</span>
                        {/if}
                    </span>
                </p>
                <p>
                    <span class="iconfont icon-dingdan"></span>
                    <span>订单号码</span>
                    <span>{$order_sn}</span>
                    <span>
                        <span>代金券:</span>
                        {if condition="$count_cash_coupon neq 0"}
                        <span class="pc-voucher-xin">选择代金券></span>
                        {else /}
                        <span>暂无代金券</span>
                        {/if}
                    </span>
                </p>
            </div>
        <!-- 支付方式选择 -->
            <div class="pc-pay">
                <i class="iconfont icon-tubiaolunkuo-"></i>
                <label for="zhifubao" onclick="p_pay_type(1)">
                    <input id="zhifubao" type="radio" value="1" name="pay_type" />
                    <img src="__STATIC__/index/img/order/zhifubao.png" alt="">
                </label>
                <label for="weixin" onclick="p_pay_type(2)">
                    <input id="weixin" type="radio" value="2" name="pay_type" />
                    <img src="__STATIC__/index/img/order/weixin.png" alt="">
                </label>
                <label for="yue" onclick="p_pay_type(3)">
                    <!--<input id="yue" type="radio" value="3" name="pay_type" {if condition="$member.user_money lt $final_amount"}disabled {/if}/>-->
                    <input id="yue" type="radio" value="3" name="pay_type" />
                    <img src="__STATIC__/index/img/order/yue.png" alt="">
                </label>
            </div>
        <!-- 备注 -->
            <div class="pc-remarks">
                <i class="iconfont icon-icon--"></i>
                <input type="text" class="p_user_note" name="user_note" placeholder="填写备注" onchange="get_user_note(this)">
            </div>
        <!-- 提交 -->
            <div class="pc-submit">
                <div>
                    <span id="pc_yunfei">运费：
                        <span class="p-yunfei">￥{$delivery_fee}</span>
                    </span>
                    <span>实际付款：
                        <span class="p-final-amount">￥{$final_amount}</span>
                    </span>
                    <a href="javascript:;" onclick="check_form()">结算</a>
                </div>
            </div>
        <!-- 添加地址 -->
            <input type="hidden" name="coupon_id" value="">
            <input type="hidden" name="coupon_price" value="0">
            <input type="hidden" name="cash_coupon_id" value="">
            <input type="hidden" name="cash_coupon_price" value="0">
            <input type="hidden" name="goods_num" value="{$num}">
            <input type="hidden" name="total_amount" value="{$total_amount}">
            <input type="hidden" name="final_amount" value="{$final_amount}">
        <!--邮费-->
            <input type="hidden" name="shipping_price" value="{$delivery_fee}">
            <input type="hidden" name="address_id" value="{$address_id}">
            <input type="hidden" name="zhifu_type" value="">
        <!--商品信息-->
            <input type="hidden" name="store_goods_stock_id" value="{$goods.0.id}">
        <!--商品id start-->
            <input type="hidden" name="goods_id" value="{$goods.0.goods_id}">
        <!--属性价格 start-->
            <input type="hidden" name="spec_price" value="{$goods.0.goods_price}">
        <!--属性id start-->
            <input type="hidden" name="spec_id" value="{$goods.0.goods_spec_id}">
            <input type="hidden" name="is_ziqu" value="0">
    </form>
    <!-- 选择优惠券 -->
    <div class="pc-discounts-popups">
        <div class="pc-discounts-popups-content">
            <p>选择优惠券
                <i class="iconfont icon-cuowu pc-discounts-esc"></i>
            </p>
            <!-- 优惠券循环开始 -->
            {foreach name="coupon" item="v"}
            <div class="pc-discounts-esc" data-id="{$v.id}" data-price="{$v.reduce}">
                <div>
                    <img src="{$v.img}" alt="">
                </div>
                <div>
                    <div>
                        <p>
                            <span>￥</span>
                            <span>{$v.reduce}</span>
                        </p>
                    </div>
                    <div>
                        <p>满{$v.morethan}减{$v.reduce}</p>
                        <p>{$v.use_start_time|date="Y-m-d",###} - {$v.use_end_time|date="Y-m-d",###}</p>
                    </div>
                </div>
            </div>
            {/foreach}
            <!-- 优惠券循环结束 -->
        </div>
    </div>
    <!-- 选择代金券 -->
    <div class="pc-voucher-popups">
        <div class="pc-voucher-popups-content">
            <p>选择代金券
                <i class="iconfont icon-cuowu pc-voucher-esc"></i>
            </p>
            <!-- 代金券循环开始 -->
            {foreach name="cash_coupon" item="v"}
            <div class="pc-voucher-esc" data-id="{$v.id}" data-price="{$v.value}">
                <div>
                    <img src="{$v.img}" alt="">
                </div>
                <div>
                    <div>
                        <p>
                            <span>￥</span>
                            <span>{$v.value}</span>
                        </p>
                        <p>
                            立减
                        </p>
                    </div>
                    <div>
                        <p>立减{$v.value}</p>
                        <p>无期限</p>
                    </div>
                </div>
            </div>
            {/foreach}
            <!-- 代金券循环结束 -->
        </div>
    </div>
    </div>
    <div class="PC" id="pc-">
        <div class="pc-address-popups">
            <div class="pc-address-popups-content">
                <p>收货地址
                    <i class="iconfont icon-cuowu pc-address-esc"></i>
                </p>
                <input type="text" name="consignee" placeholder="请填写联系人">
                <!--
                  在这里判断错误的时候 加上这个 cuowu 这个类名  如果正确  就删除这个类名
               -->
                <!--<div class="cuowu">-->
                <div id="address_mobile">
                    <input type="text" placeholder="请填写联系方式" name="mobile">
                    <span>格式错误</span>
                </div>
                <select name="city" id="address_city">
                    {foreach name="city" item="v"}
                    <option value="{$v.value}">{$v.value}</option>
                    {/foreach}
                </select>
                <input type="text" name="address" placeholder="请填写详细地址">
                <p>
                    <input type="checkbox" name="is_default" id="" value="1">
                    <span>设为默认地址</span>
                </p>
                <a href="javascript:;" onclick="add_address();">保存</a>
            </div>
        </div>
        {include file="public/p_footer" /}
    </div>
    <script>
        $(function () {
            // pc端选择地址方式
            $('.pc-xuanze').click(function () {
                var type = $(this).attr('data-id');
                var total_amount = "{$total_amount}";           //商品价格
                var yunfei = parseFloat($('input[name=shipping_price]').val()).toFixed(2);           //商品价格
                $('input[name=is_ziqu]').val(type);
                if(type == 0){          //外卖,显示运费
                    total_amount = parseFloat(parseFloat(yunfei)+parseFloat(total_amount)).toFixed(2);
                    $('#pc_yunfei').css('display','block');
                    $('#m_yunfei').css('display','block');
                    $('#m_yunfei').next().removeClass('m-gao');
                    $('.p-yunfei').text('￥'+yunfei);
                    $('.m-yunfei').text('￥'+yunfei);
                    $('.m-final-amount').text('￥'+total_amount);
                    $('.p-final-amount').text('￥'+total_amount);
                }else{      //自取
                    $('#pc_yunfei').css('display','none');
                    $('#m_yunfei').css('display','none');
                    $('#m_yunfei').next().addClass('m-gao');
                    $('.m-final-amount').text('￥'+total_amount);
                    $('.p-final-amount').text('￥'+total_amount);
                }



                var number = $(this).index();
                $('.pc-xuanze').removeClass('pc-xuanze-zhong');
                $('.pc-xuanze').eq(number).addClass('pc-xuanze-zhong');
                $('.pc-xuan-content').css('display', 'none');
                $('.pc-xuan-content').eq(number).css('display', 'block');
                // 移动端同步
                $('.m-xuanze').removeClass('m-xuanze-zhong');
                $('.m-xuanze').eq(number).addClass('m-xuanze-zhong');
                $('.m-xuan-content').css('display', 'none');
                $('.m-xuan-content').eq(number).css('display', 'block');
            });
            $('.m-xuanze').click(function () {

                var type = $(this).attr('data-id');
                var total_amount = "{$total_amount}";           //商品价格
                var yunfei = parseFloat($('input[name=shipping_price]').val()).toFixed(2);           //商品价格
                $('input[name=is_ziqu]').val(type);
                if(type == 0){          //外卖,显示运费
                    total_amount = parseFloat(parseFloat(yunfei)+parseFloat(total_amount)).toFixed(2);
                    $('#pc_yunfei').css('display','block');
                    $('#m_yunfei').css('display','block');
                    $('#m_yunfei').next().removeClass('m-gao');
                    $('.p-yunfei').text('￥'+yunfei);
                    $('.m-yunfei').text('￥'+yunfei);
                    $('.m-final-amount').text('￥'+total_amount);
                    $('.p-final-amount').text('￥'+total_amount);
                }else{      //自取
                    $('#pc_yunfei').css('display','none');
                    $('#m_yunfei').css('display','none');
                    $('#m_yunfei').next().addClass('m-gao');
                    $('.m-final-amount').text('￥'+total_amount);
                    $('.p-final-amount').text('￥'+total_amount);
                }


                var number = $(this).index();
                $('.m-xuanze').removeClass('m-xuanze-zhong');
                $('.m-xuanze').eq(number).addClass('m-xuanze-zhong');
                $('.m-xuan-content').css('display', 'none');
                $('.m-xuan-content').eq(number).css('display', 'block');
                // PC端同步
                $('.pc-xuanze').removeClass('pc-xuanze-zhong');
                $('.pc-xuanze').eq(number).addClass('pc-xuanze-zhong');
                $('.pc-xuan-content').css('display', 'none');
                $('.pc-xuan-content').eq(number).css('display', 'block');
            });
            // 优惠券
            $('.m-discounts-xuan').click(function () {
                $('body').css('overflow', 'hidden');
                $('.m-discounts-popups').css('display', 'block');
                $('.m-discounts-popups-content').animate({
                    bottom: '0',
                });
            });
            $('.m-discounts-esc').click(function () {
                $('.m-discounts-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.m-discounts-popups-content').animate({
                    bottom: '-400',
                });
            }); // 优惠券
            //            $('.m-discount-xuan').click(function () {
            //                $('body').css('overflow', 'hidden');
            //                $('.m-discount-popups').css('display', 'block');
            //                $('.m-discount-popups-content').animate({
            //                    bottom: '0',
            //                });
            //            });
            //
            //            $('.m-discount-esc').click(function () {
            //                $('.m-discount-popups').css('display', 'none');
            //                $('body').css('overflow', 'scroll');
            //                $('.m-discount-popups-content').animate({
            //                    bottom: '-400',
            //                });
            //            });
            // pc端
            $('.pc-address-xin').click(function () {
                $('body').css('overflow', 'hidden');
                $('.pc-address-popups').css('display', 'block');
                $('.pc-address-popups-content').animate({
                    bottom: '0',
                });
            });
            $('.pc-address-esc').click(function () {
                $('.pc-address-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.pc-address-popups-content').animate({
                    bottom: '-400',
                });
            });
            //            // 优惠券
            //            $('.pc-discounts-xin').click(function () {
            //                $('body').css('overflow', 'hidden');
            //                $('.pc-discounts-popups').css('display', 'block');
            //                $('.pc-discounts-popups-content').animate({
            //                    bottom: '0',
            //                });
            //            });
            // --------------------------------------新添加开始----------------------------
            // 移动端地址选择
            $('.pc-discounts-xin').click(function () {
                $('body').css('overflow', 'hidden');
                $('.pc-discounts-popups').css('display', 'block');
                $('.pc-discounts-popups-content').animate({
                    bottom: '0',
                });
            });
            // 关闭弹出层
            $('.pc-discounts-esc').click(function () {
                $('.pc-discounts-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.pc-discounts-popups-content').animate({
                    bottom: '-400',
                });
            });
            // 对勾切换
            $('.m-address-xuanze').click(function () {
                $('.m-address-xuanze').removeClass('m-address-zhong');
                $(this).addClass(' m-address-zhong');
                var id = $(this).attr('data-id');
                //计算运费
                //                $('.pc-address-content').css('border', 'solid 1px #d5d5d5');
                //                console.log($(obj));
                //                $(obj).css('border', 'solid 1px #f83030');
                //                $('.pc-address-content').removeClass('cur_address');
                //                $(obj).addClass('cur_address');
                //
                //                var id = $(obj).attr('data-id');
                //                var consignee = $(obj).attr('data-consignee');
                //                var mobile = $(obj).attr('data-mobile');
                var address = $(this).attr('data-address');
                $.post("{:url('GoodsList/get_dada_delivery')}", {
                        address: address,
                    },
                    function (data) {
                        if (data.code == 1) {
                            //订单原始支付金额
                            var total_amount = "{$total_amount}";
                            var credit = "{$member.user_money}"; //会员的余额
                            var coupon_price = parseFloat($('input[name=coupon_price]').val()); //会员的余额
                            var cash_coupon_price = parseFloat($('input[name=cash_coupon_price]').val());; //会员的余额
                            $('input[name=address_id]').val(id);
                            $('input[name=shipping_price]').val(data.data);
                            //                        $('input[name=delivery_fee]').val(data.data);
                            $('#delivery_fee').text(data.data);
                            var final_amount = parseFloat(parseFloat(total_amount) + parseFloat(
                                    data.data) - parseFloat(
                                    coupon_price) - parseFloat(cash_coupon_price)).toFixed(2);
                            $('.p-final-amount').text(final_amount);
                            $('.m-final-amount').text(final_amount);
                            $('input[name=final_amount]').val(final_amount);
                            $('input[name=shipping_price]').val(data.data);
                            $('.p-yunfei').text('￥'+data.data);
                            $('.m-yunfei').text('￥'+data.data);
                            $('input[name=address_id]').val(id);
                            $('.pc-address-content').removeClass('cur_address');
                            $('.pc-address-content').css('border', 'solid 1px rgb(213, 213, 213)');
                            $('.pc-address-content[data-id=' + id + ']').addClass('cur_address');
                            $('.pc-address-content[data-id=' + id + ']').css('border',
                                '1px solid rgb(248, 48, 48)');
                            var m_address = $('.m-address-xuanze[data-id=' + id + ']').find(
                                '.m-sh-address').text();
                            var m_consignnn = $('.m-address-xuanze[data-id=' + id + ']').find(
                                '.m-sh-consignee').text();
                            var m_mobile = $('.m-address-xuanze[data-id=' + id + ']').find(
                                '.m-sh-mobile').text();
                            console.log(m_address);
                            $('.m-default-address').text(m_address);
                            $('.m-default-consignee').text(m_consignnn);
                            $('.m-default-mobile').text(m_mobile);
                            //                        if(credit < final_amount){
                            //                            $('#yue').attr('checked',false);
                            //                            $('.m_pay').eq(2).removeClass('m-pay-zhong');
                            //                        }else{
                            //                            $('#yue').removeAttr('disable');
                            //                        }
                        } else {
                            layer.msg('地址信息有误，请重新选择', {
                                icon: 2,
                                time: 1500,
                                shade: 0.1
                            }, function (index) {
                                layer.close(index);
                            });
                            return false;
                        }
                    }
                );
                $('.m-address-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.m-address-popups-content').animate({
                    bottom: '-400',
                });
            });
            // 添加地址移动端弹出层
            $('.m-tianjia').click(function () {
                $('body').css('overflow', 'hidden');
                $('.m-address-xin').css('display', 'block');
                $('.m-address-xin-content').animate({
                    bottom: '0',
                });
            }); // 关闭弹出层 添加地址移动端
            $('.m-tianjia-esc').click(function () {
                $('.m-address-xin').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.m-address-xin-content').animate({
                    bottom: '-400',
                });
            });
            // 移动端默认地址选择
            $('#m-tacitly').change(function () {
                if ($(this).is(':checked')) {
                    console.log('1====>', $(this).is(':checked'))
                    $('#m-tacitly-img').css('display', 'inline-block');
                } else {
                    $('#m-tacitly-img').css('display', 'none');
                    console.log(2);
                }
            });
            $('.m-address').click(function () {
                $('body').css('overflow', 'hidden');
                $('.m-address-popups').css('display', 'block');
                $('.m-address-popups-content').animate({
                    bottom: '0',
                });
            });
            $('.m-address-esc').click(function () {
                $('.m-address-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.m-address-popups-content').animate({
                    bottom: '-400',
                });
            });
            //优惠券
            $('.pc-discounts-esc').click(function () {
                $('.pc-discounts-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.pc-discounts-popups-content').animate({
                    bottom: '-400',
                });
                var create = "{$member.user_money}"; //会员的余额
                if ($(this).attr('data-id') != undefined) { //
                    var yunfei = parseFloat($('input[name=shipping_price]').val()); //运费
                    var total_amount = parseFloat($('input[name=total_amount]').val()); //纯商品价格
                    var cash_coupon_price = parseFloat($('input[name=cash_coupon_price]').val()); //代金券价格
                    var reduce = parseFloat($(this).attr('data-price')).toFixed(2);
                    var coupon_id = $(this).attr('data-id');
                    $('input[name=coupon_id]').val(coupon_id); //优惠券id
                    $('input[name=coupon_price]').val(reduce); //优惠券价格
                    $('.m-discounts-xuan').text('立减' + reduce);
                    $('.pc-discounts-xin').text('立减' + reduce);
                    var final_amount = parseFloat(total_amount + yunfei - cash_coupon_price - reduce).toFixed(
                        2);
                    $('input[name=final_amount]').val(final_amount);
                    $('.p-final-amount').text('￥' + final_amount);
                    $('.m-final-amount').text('￥' + final_amount);
                    //                    if(create < final_amount){
                    //                        $('#yue').attr('disable',true);
                    //                    }else{
                    //                        $('#yue').removeAttr('disable');
                    //                    }
                }
            });
            $('.youhuiuan-change').click(function () {
                $('.m-discounts-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.pc-discounts-popups-content').animate({
                    bottom: '-400',
                });
                var create = "{$member.user_money}"; //会员的余额
                if ($(this).attr('data-id') != undefined) { //
                    var yunfei = parseFloat($('input[name=shipping_price]').val()); //运费
                    var total_amount = parseFloat($('input[name=total_amount]').val()); //纯商品价格
                    var cash_coupon_price = parseFloat($('input[name=cash_coupon_price]').val()); //代金券价格
                    var reduce = parseFloat($(this).attr('data-price')).toFixed(2);
                    var coupon_id = $(this).attr('data-id');
                    $('input[name=coupon_id]').val(coupon_id); //优惠券id
                    $('input[name=coupon_price]').val(reduce); //优惠券价格
                    $('.m-discounts-xuan').text('立减' + reduce);
                    $('.pc-discounts-xin').text('立减' + reduce);
                    var final_amount = parseFloat(total_amount + yunfei - cash_coupon_price - reduce).toFixed(
                        2);
                    $('input[name=final_amount]').val(final_amount);
                    $('.p-final-amount').text('￥' + final_amount);
                    $('.m-final-amount').text('￥' + final_amount);
                    //                    if(create < final_amount){
                    //                        $('#yue').attr('disable',true);
                    //                    }else{
                    //                        $('#yue').removeAttr('disable');
                    //                    }
                }
            })
            // 代金券
            $('.pc-voucher-xin').click(function () {
                $('body').css('overflow', 'hidden');
                $('.pc-voucher-popups').css('display', 'block');
                $('.pc-voucher-popups-content').animate({
                    bottom: '0',
                });
            });
            //代金券
            $('.pc-voucher-esc').click(function () {
                $('.pc-voucher-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.pc-voucher-popups-content').animate({
                    bottom: '-400',
                });
                var create = "{$member.user_money}"; //会员的余额
                if ($(this).attr('data-id') != undefined) {
                    var yunfei = parseFloat($('input[name=shipping_price]').val()); //运费
                    var total_amount = parseFloat($('input[name=total_amount]').val()); //纯商品价格
                    var coupon_price = parseFloat($('input[name=coupon_price]').val()); //代金券价格
                    var reduce = parseFloat($(this).attr('data-price')).toFixed(2);
                    var coupon_id = $(this).attr('data-id');
                    $('input[name=cash_coupon_id]').val(coupon_id); //优惠券id
                    $('input[name=cash_coupon_price]').val(reduce); //优惠券价格
                    $('.m-voucher-xuan').text('立减' + reduce);
                    $('.pc-voucher-xin').text('立减' + reduce);
                    var final_amount = parseFloat(total_amount + yunfei - coupon_price - reduce).toFixed(
                        2);
                    $('input[name=final_amount]').val(final_amount);
                    $('.p-final-amount').text('￥' + final_amount);
                    $('.m-final-amount').text('￥' + final_amount);
                    //                    if(create < final_amount){
                    //                        $('#yue').attr('disable',true);
                    //                    }else{
                    //                        $('#yue').removeAttr('disable');
                    //                    }
                }
            });
            $('.m_daijinquan').click(function () {
                $('.m-discount-popups').css('display', 'none');
                $('body').css('overflow', 'scroll');
                $('.pc-voucher-popups-content').animate({
                    bottom: '-400',
                });
                var create = "{$member.user_money}"; //会员的余额
                if ($(this).attr('data-id') != undefined) {
                    var yunfei = parseFloat($('input[name=shipping_price]').val()); //运费
                    var total_amount = parseFloat($('input[name=total_amount]').val()); //纯商品价格
                    var coupon_price = parseFloat($('input[name=coupon_price]').val()); //代金券价格
                    var reduce = parseFloat($(this).attr('data-price')).toFixed(2);
                    var coupon_id = $(this).attr('data-id');
                    $('input[name=cash_coupon_id]').val(coupon_id); //优惠券id
                    $('input[name=cash_coupon_price]').val(reduce); //优惠券价格
                    $('.m-voucher-xuan').text('立减' + reduce);
                    $('.pc-voucher-xin').text('立减' + reduce);
                    var final_amount = parseFloat(total_amount + yunfei - coupon_price - reduce).toFixed(
                        2);
                    $('input[name=final_amount]').val(final_amount);
                    $('.p-final-amount').text('￥' + final_amount);
                    $('.m-final-amount').text('￥' + final_amount);
                    //                    if(create < final_amount){
                    //                        $('#yue').attr('disable',true);
                    //                    }else{
                    //                        $('#yue').removeAttr('disable');
                    //                    }
                }
            });
            //            $('.pc-address-content').click(function () {
            //                $('.pc-address-content').css('border', 'solid 1px #d5d5d5');
            //                $(this).css('border', 'solid 1px #f83030');
            //                $('.pc-address-content').removeClass('cur_address');
            //                $(this).addClass('cur_address');
            //            });
        })
        // 地址选择 加红色边框
        function change_address(obj) {
            var id = $(obj).attr('data-id');
            var consignee = $(obj).attr('data-consignee');
            var mobile = $(obj).attr('data-mobile');
            var address = $(obj).attr('data-address');
            $.post("{:url('GoodsList/get_dada_delivery')}", {
                    address: address,
                    id: id,
                    mobile: mobile,
                    consignee: consignee
                },
                function (data) {
                    if (data.code == 1) {
                        //订单原始支付金额
                        var total_amount = "{$total_amount}";
                        var credit = "{$member.user_money}"; //会员的余额
                        var coupon_price = parseFloat($('input[name=coupon_price]').val()); //会员的余额
                        var cash_coupon_price = parseFloat($('input[name=cash_coupon_price]').val());; //会员的余额
                        $('input[name=address_id]').val(id);
                        $('input[name=shipping_price]').val(data.data);
                        //                        $('input[name=delivery_fee]').val(data.data);
                        $('#delivery_fee').text(data.data);
                        var final_amount = parseFloat(parseFloat(total_amount) + parseFloat(data.data) - parseFloat(coupon_price) - parseFloat(cash_coupon_price)).toFixed(2);
                        $('.p-final-amount').text('￥'+final_amount);
                        $('.m-final-amount').text('￥'+final_amount);
                        $('input[name=final_amount]').val(final_amount);
                        $('input[name=shipping_price]').val(data.data);
                        $('.p-yunfei').text('￥'+data.data);
                        $('.m-yunfei').text('￥'+data.data);
                        $('.pc-address-content').css('border', 'solid 1px #d5d5d5');
                        $('.p-yunfei').text('￥'+data.data);
                        $('.m-yunfei').text('￥'+data.data);
                        $(obj).css('border', 'solid 1px #f83030');
                        $('.pc-address-content').removeClass('cur_address');
                        $(obj).addClass('cur_address');
                        $('.m-address-xuanze').removeClass('m-address-zhong');
                        $('.m-address-xuanze[data-id=' + id + ']').addClass('m-address-zhong');
                        var m_address = $('.m-address-xuanze[data-id=' + id + ']').find('.m-sh-address').text();
                        var m_consignee = $('.m-address-xuanze[data-id=' + id + ']').find('.m-sh-consignee').text();
                        var m_mobile = $('.m-address-xuanze[data-id=' + id + ']').find('.m-sh-mobile').text();
                        $('.m-default-address').text(m_address);
                        $('.m-default-consignee').text(m_consignee);
                        $('.m-default-mobile').text(m_mobile);
                        //                        if(credit < final_amount){
                        //                            $('#yue').attr('checked',false);
                        //                            $('.m_pay').eq(2).removeClass('m-pay-zhong');
                        //                        }else{
                        //                            $('#yue').removeAttr('disable');
                        //                        }
                    } else {
                        layer.msg('地址信息有误，请重新选择', {
                            icon: 2,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                        });
                        return false;
                    }
                }
            );
        }
    </script>
    <script>
        /**
         * 保存新增的收货地址
         */
        function add_address() {
            var reg = /^1[34578]\d{9}$/;
            var consignee = $('input[name=consignee]').val();
            var mobile = $('input[name=mobile]').val();
            var city = $('#address_city option:selected').val();
            var address = $('input[name=address]').val();
            var is_default = 0;
            if ($('input[name=is_default]:checked') == undefined) {
                is_default = 0;
            } else {
                is_default = 1;
            }
            if ($.trim($('input[name=mobile]').val()) == '') {
                layer.msg('请输入手机号', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
                return false;
            }
            if (!reg.test($('input[name=mobile]').val())) {
                layer.msg('手机号格式错误，请重新填写', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            if (city == '') {
                layer.msg('请选择所在城市', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            if (address == '') {
                layer.msg('请输入详细地址', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            $.post("{:url('GoodsList/add_edit_address')}", {
                    consignee: consignee,
                    mobile: mobile,
                    city: city,
                    address: address,
                    is_default: is_default
                },
                function (data) {
                    if (data.code == 1) {
                        location.reload();
                        //                        if(is_default == 1){
                        //                            $('.pc-address-content').removeClass('cur_address');
                        //                            $('.pc-address-content').removeAttr('style');
                        //                        }
                        //2018-05-11
                        //                        var html = '<div class="pc-address-content" data-id="' + data.data + '" data-address="' +
                        //                            address + '" data-consignee="' + consignee + '" data-mobile="' + mobile +
                        //                            '" onclick="change_address(this)"><p>' + consignee +
                        //                            '<i class="iconfont icon-dizhi"></i></p><p>' + mobile + '</p><p>' + city + '</p><p>' +
                        //                            address + '</p></div>';
                        //                        $('#p_address_list').before(html);
                        //
                        //                        $('.pc-address-popups').css('display', 'none');
                        //                        $('body').css('overflow', 'scroll');
                        //                        $('.pc-address-popups-content').animate({
                        //                            bottom: '-400',
                        //                        });
                        //
                        //                        $('input[name=consignee]').val('');
                        //                        $('input[name=mobile]').val('');
                        //                        $('#address_city').val('');
                        //                        $('input[name=address]').val('');
                        //                        $('input[name=is_default]').val('');
                        //2018-05-11
                    } else {
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                        });
                        return false;
                    }
                }
            );
        }
        /**
         * 返回
         */
        function go_back() {
            window.history.go(-1); //返回上一页
        }
        /**
         * 取消订单
         * @returns {boolean}
         */
        function quxiao_order() {
            layer.msg('取消成功', {
                icon: 1,
                time: 1500,
                shade: 0.1
            }, function (index) {
                layer.close(index);
                window.location.href = "{:url('GoodsList/goods_list')}";
            });
            return false;
        }
        /**
         * 移动端改变支付方式
         */
        function m_change_pay(obj) {
            $('.m_pay').removeClass('m-pay-zhong');
            $(obj).addClass('m-pay-zhong');
            $('input[name=pay_type]').val($('.m-pay-zhong').attr('data-type'));
            if ($(obj).attr('data-type') == 1) {
                $('input[name=pay_type]').eq(0).attr('checked', 'checked');
                $('input[name=zhifu_type]').val(1);
            } else if ($(obj).attr('data-type') == 2) {
                $('input[name=pay_type]').eq(1).attr('checked', 'checked');
                $('input[name=zhifu_type]').val(2);
            } else {
                $('input[name=pay_type]').eq(2).attr('checked', 'checked');
                $('input[name=zhifu_type]').val(3);
            }
        }
        function p_pay_type(id) {
            $('input[name=zhifu_type]').val(id);
            if (id == 1) {
                $('.m_pay').removeClass('m-pay-zhong');
                $('.m_pay').eq(0).addClass('m-pay-zhong');
            } else if (id == 2) {
                $('.m_pay').removeClass('m-pay-zhong');
                $('.m_pay').eq(1).addClass('m-pay-zhong');
            } else {
                $('.m_pay').removeClass('m-pay-zhong');
                $('.m_pay').eq(2).addClass('m-pay-zhong');
            }
        }
        /**
         * 复制内容到会员备注中
         */
        function get_user_note(obj) {
            var note = $(obj).val();
            $('input[name=user_note]').val(note);
            $('input[name=user_note]').val(note);
        }
        /**
         *  提交订单检测
         */
        function check_form() {
            var credit = "{$member.user_money}"; //会员余额
            var coupon_id = $('input[name=coupon_id]').val();
            var coupon_price = $('input[name=coupon_price]').val();
            var cash_coupon_id = $('input[name=cash_coupon_id]').val();
            var cash_coupon_price = $('input[name=cash_coupon_price]').val();
            var goods_num = $('input[name=goods_num]').val();
            var total_amount = $('input[name=total_amount]').val();
            var final_amount = $('input[name=final_amount]').val();
            var user_note = $('input[name=user_note]').val();
            var address_id = $('input[name=address_id]').val();
            var pay_type = $('input[name=zhifu_type]').val();
            if (pay_type == '') {
                layer.msg('请选择付款方式', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            if ((pay_type == 3) && (parseFloat(credit) < parseFloat(final_amount))) { //判断月支付余额是否充足
                layer.msg('您的余额不足，请选择其它支付方式', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            if (address_id == '') {
                layer.msg('请选择收货地址', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            if ($('input[name=goods_id]').val() == '') {
                layer.msg('找不到商品信息，请重新选购商品', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                    window.location.href = "{:url('GoodsList/goods_list')}";
                });
                return false;
            }
            $('#order_form').submit();
        }
        /**
         * 移动端新增收货地址
         */
        function m_post_address() {
            var address = $('input[name=m_address]').val();
            var consignee = $('input[name=m_consignee]').val();
            var mobile = $('input[name=m_mobile]').val();
            var city = $('#m_city option:selected').val();
            var is_default = $('input[name=m_default]').val();
            if (is_default == undefined) {
                is_default = 0;
            } else {
                is_default = 1;
            }
            if (address == '') {
                layer.msg('请填写收货地址', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            if (consignee == '') {
                layer.msg('请填写收货人', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            if (mobile == '') {
                layer.msg('请填写联系人电话', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            if (city == '') {
                layer.msg('请选择城市', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
            }
            $.post("{:url('GoodsList/add_edit_address')}",
                {
                    address: address,
                    consignee: consignee,
                    mobile: mobile,
                    city: city,
                    is_default: is_default
                },
                function (data) {
                    if (data.code == 1) {
                        layer.msg('添加成功', {
                            icon: 1,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                            location.reload();
                        });
                    } else {
                        layer.msg(dada, msg, {
                            icon: 2,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                            location.reload();
                        });
                    }
                }
            );
        }
    </script>
</body>
</html>